/**
 created by 杨小北
 */
var Utils = {
  stringFormat: function (t, e) {
    return t.replace(/\{\{(.+?)}}/g, function (t, r) {
      return e[r]
    })
  }, dateFormat: function (t, e) {
    var r = {
      "M+": t.getMonth() + 1,
      "d+": t.getDate(),
      "h+": t.getHours(),
      "m+": t.getMinutes(),
      "s+": t.getSeconds(),
      "q+": Math.floor((t.getMonth() + 3) / 3),
      S: t.getMilliseconds()
    };
    /(y+)/.test(e) && (e = e.replace(RegExp.$1, (t.getFullYear() + "").substr(4 - RegExp.$1.length)));
    for (var n in r)new RegExp("(" + n + ")").test(e) && (e = e.replace(RegExp.$1, 1 == RegExp.$1.length ? r[n] : ("00" + r[n]).substr(("" + r[n]).length)));
    return e
  }, parseQuery: function (t, e) {
    var r, n = {};
    return t = t || location.search.substr(1), e = e || "&", r = t.split(e), r.forEach(function (t, e) {
      if ("" !== t) {
        var r = t.split("=");
        n[r[0]] = r[1]
      }
    }), n
  },
  leftBarClick:function () {
    $("li")
      .on('click',function () {
        $(this).toggleClass("open").end().find('ul').toggleClass('open');
        if ($(this).hasClass('open')){
          $(this).find('ul').css('display','none').slideToggle(500);
        }else{
          $(this).find('ul').css('display','block').slideToggle(500);
        }
      });
  },
  checkCookie:function () {
    // return;
    if (!/mid=/.test(document.cookie)||$.cookie('mid')=='') {
      location.href = '../../index.html';
    }
    return false;
  },
  setCookie:function () {

  },
  alertMessage: function (params) {
    if (!params.hasOwnProperty('message')) params.message = '操作失败，请求错误'
    var DEFAULT = {
      container: '#portlet-data',
      place: 'prepend',
      type: 'success',
      message: 'message',
      close: true,
      reset: true,
      focus: false,
      icon: 'check'
    }, opt;
    opt = $.extend({}, DEFAULT, params);
    Metronic.alert(opt);
  },
  checkMobile:function (mobile) {
    if (!(/^1[134578]\d{9}$/.test(mobile))){
      return false;
    }
    return true;
  },
  debug:true,
  orderDateFormat:function (oid) {
    return oid.substr(0,2)+'月'+oid.substr(2,2)+'日 '
  }
};

var IP = 'http://www.status500.com';
// IP='http://192.168.1.105:8080';
// IP = 'http://cococrush.chanel.cn';
// IP = 'http://leseauxpodium.chanel.com.cn';
IP = 'http://uat.ripple-corp.com';
IP = 'http://campaign.chanel.com.cn';


var CONST = {
  URL: {
    LOGIN:              IP+'/podium-manager/bg_login',   //登陆
    FIND_PODIUMS:               IP+'/podium-manager/find_podiums',
    FINDALL:            IP+'/rcc-poduim-manage/data/findAll',
    FIND_BC:             IP+'/podium-manager/find_bc',
    GET_DS:             IP+'/podium-manager/get_ds',
    FIND_ACL:             IP+'/podium-manager/find_acl',
    CLEAR:          IP+'/podium-manager/clear',
    RESEND_SMS:          IP+'/podium-manager/resend_sms',
    NEW:                IP+'/rcc-poduim-manage/data/new',
    EDITMAX:            IP+'/rcc-poduim-manage/data/editMax',  //
    EDITSWITCH:         IP+'/rcc-poduim-manage/data/editSwitch',  //
    AGGREGATION:        IP+'/rcc-poduim-manage/data/aggregation',  //
    CHANNEL:            IP+'/rcc-poduim-manage/data/aggregationChannel',  //
    FINDSHOPPING:       IP+'/rcc-poduim-manage/data/find_shopping',
    MANAGERALL:         IP+'/rcc-poduim-manage/manager/all',
    WHITELIST:          IP+'/rcc-poduim-manage/data/getWhiteList',
    SEARCHWHITELIST:    IP+'/rcc-poduim-manage/data/searchWhiteList',
    EDITWHITELIST :     IP+'/rcc-poduim-manage/data/editWhiteList',

    BGMLOGIN:              IP+'/leseauxpodium/bgm_login',   //登陆
    FIND_ALL:               IP+'/leseauxpodium/find_all',
    FINDBCARD:           IP+'/leseauxpodium/find_bcard',     //查找日期城市

    // FINDALL:            IP+'/rcc-poduim-manage/data/findAll',
    FIND_BM:             IP+'/leseauxpodium/find_bm',
    BGMAC:             IP+'/leseauxpodium/bgm_ac',
    BGMAT:             IP+'/leseauxpodium/bgm_at',     //活動時間
    STAT:                IP+'/leseauxpodium/bgm_sd',
    RMOVER_GUEST:                IP+'/leseauxpodium/remove_guest',

  },
  USER_TYPE : [
    '普通用户',
    'FA',
    'KOL',
    '内部员工',
    'PASSBY',
    'PARTY',
  ],
  CITY_TYPE : {
    '0':'普通用户',
    '1':'FA',
    '2':'KOL',
    '3':'Internal',
    '4':'Passby',
    '5':'PARTY',
  },
};



var REQUEST = {
  GET:function (url,data,callback) {
    $.ajax({
      url:url,
      method:"GET",
      success:function (result) {
        console.log(3333)
        callback(result,"success");
      },
      error:function (error) {
        callback(error,"error");
      }
    })
  },
  POST:function (url,data,callback) {
    $.ajax({
      url:url,
      method:"POST",
      dataType: 'JSON',
      contentType: 'application/json',
      data:JSON.stringify(data),
      success:function (result) {
        callback(result,"success");
      },
      error:function (error) {
        callback(error,"error");
      }
    })
  },
  TIPS:{
    '10001':"数据库操作失败",
    '10002':"手机号已存在",
    '10003':"人数超出限制",
    '10004':"用户不存在",
    '10005':"操作被驳回",
    '10006':"短信发送失败",
    '10007':"管理员没有该权限",
    '10008':"管理员登录失败",
    '10009':"短链接错误",
    '10010':"不在白名单"
  },
}


var ERROR = {
  '10001':"数据库操作失败",
  '10002':"手机号已存在",
  '10003':"人数超出限制",
  '10004':"用户不存在",
  '10005':"操作被驳回",
  '10006':"短信发送失败",
  '10007':"非白名单用户",
  '10008':"管理员登录失败",
  '10009':"短链接错误",
}


// BACKEND, MKT, PR, AD, MEDIA

var City = {
  // 'Chengdu':'成都',
  // 'Chongqing':'重庆',
  // 'Harbin':'哈尔滨',
  // 'Qingdao':'青岛',
  // 'Taiyuan':'太原',
  // 'Changchun':'长春',
  // 'Guiyang':'贵阳',
  //  'Nanchang':'南昌',
  // 'Kunming':'昆明',
  // 'Wuhan':'武汉',
  // 'Guangzhou':'广州',
  'hangzhou':'杭州',
  'shenzhen':'深圳',
  'guangzhou':'广州',
  'zhengzhou':'郑州',
  'changsha':'长沙',
  'taiyuan':'太原',
  'chongqing':'重庆',
  'hangzhouB':'杭州0815'


}
var Citys={
  "City1":{
    'chengdu':'成都',
    'hefei':'合肥',
    'shenzhen':'深圳',
    'shanghai':'上海',
    'xian':'西安',
    'haerbin':'哈尔滨',
    'nanjing':'南京',
    'lanzhou':'兰州'
  },
  "City2": {
    '成都':'chengdu',
    '合肥':'hefei',
    '深圳':'shenzhen',
    '上海':'shanghai',
    '西安':'xian',
    '哈尔滨':'haerbin',
    '南京':'nanjing',
    '兰州':'lanzhou'
  }
}



// $(".page-sidebar-menu")
//   .on('click', '.start', function () {
//     if (!$(this).hasClass('open')) {
//       $(this).siblings().each(function (index, item) {
//         if (item.classList.contains('open')) {
//           item.classList.remove('open')
//           $(item).find('.sub-menu').slideToggle(200)
//         }
//       })
//       $(this).addClass('open')
//     }else {
//       $(this).removeClass('open')
//     }
//     $(this).find('.sub-menu').slideToggle(200)
//   })

// export default Citys;
export {ERROR,Citys,REQUEST,CONST} ;




